<?php 

class BrandController extends VerifyController{
	public $model;
	
	public function __init(){
		$this->model = K("Brand");
	}
	public function index(){
		$data = $this->model->all();
		$this->assign("data",$data);
	    $this->display();
	}
	public function add(){
		if(IS_POST){
			if(!$this->model->addData()){
				$this->error($this->model->error);
			}
			$this->success("添加成功");
		}
		$this->display();
	}
	public function edit(){
		$bid = Q("get.bid");
		if(IS_POST){
			if(!$this->model->editDate($bid)){
				$this->error($this->model->error);
			}
			$this->success("更新成功");
		}
		$oldData = $this->model->where("bid={$bid}")->find();
		$this->assign("data",$oldData);
	    $this->display();
	}
	public function del(){
		$bid = Q("get.bid");		
		if(!$this->model->where("bid={$bid}")->delete()){
			$this->error($this->model->error);
		}
		$this->success("删除成功",U('index'));
	}
}
